//
//  NetworkRequest+Login.m
//  URLDemo
//
//  Created by rimi on 15/10/8.
//  Copyright © 2015年 yangqin. All rights reserved.
//

#import "NetworkRequest+Login.h"

@implementation NetworkRequest (Login)
- (void)getLoginDataWithParameters:(NSDictionary *)parameters successHandle:(SuccessBlock)success failureHandle:(failureBlock)faile {
    NSString *tokenID = [[NSUserDefaults standardUserDefaults]objectForKey:@"tokenID"];
    tokenID = tokenID == nil ? @"0" : tokenID;
    NSMutableDictionary *parameterDic = [NSMutableDictionary dictionaryWithDictionary:parameters];
    parameterDic[@"UDID"] = @"FFFFFFFFAC4A9DBE8005463697C15AADEA639730";
    parameterDic[@"TOKENID"] = tokenID;

    [self post:kLoginURL parameters:parameterDic successHandle:^(NSString *responds) {
        if (success) {
            NSLog(@"%@",[self parse2:responds]);
            success([self parse2:responds]);
            
        }
    } failureHandle:^(NSError *error) {
        
    }];
}

- (NSDictionary *) parse2:(NSString *)parseStr {
    NSMutableDictionary *rtnDic = [NSMutableDictionary dictionary];
    Parse *parse = [[Parse alloc] init];
    rtnDic[@"isOk"] = [parse parse:parseStr nodePath:@"//isOk"].firstObject;
    rtnDic[@"errorMes"] = [parse parse:parseStr nodePath:@"//errorMes"].firstObject;
    return rtnDic;
}
@end
